package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.ImageActivity;
import com.red.star.wechat.data.entity.Mall;
import com.red.star.wechat.data.entity.bo.ImageAreaBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.red.star.wechat.data.entity.vo.ImageActivityVO;

import java.util.List;
import java.util.Map;

/**
 * @author xuquanyu
 * @date 2018/9/25.
 * 裂变图片活动
 */
public interface ImageActivityMapper extends MyMapper<ImageActivity> {

    List<ImageActivity> imageActivityList(ImageActivity imageActivity);

    List<Mall> selectCityListByProvinceCode(@Param("provinceCode") String provinceCode);

    @Select(value = "select distinct t.b_region_code,t.b_region_name from t_mall t  where t.b_region_code is not null and t.b_region_code != '' and t.b_region_name != '' and t.b_region_name is not null")
    List<Mall> selectBRegionCodeList();

    @Select(value = "select distinct t.m_region_code from t_mall t where t.m_region_code is not null")
    List<Mall> selectMRegionCodeList();

    @Select(value = "select distinct t.s_region_code,t.s_region_name from t_mall t where t.s_region_code is not null and t.s_region_code != '' and t.s_region_name != '' and t.s_region_name is not null")
    List<Mall> selectSRegionCodeList();

    @Select(value = "select distinct t.province_code, t.province from t_mall t")
    List<Mall> selectProvinceCodeList();

    List<ImageActivityVO> findByCondition(@Param("imageActivityVOList") List<ImageActivityVO> imageActivityVOList);

    ImageAreaBo selectMallByCondition(@Param("type") Integer type,
                                      @Param("typeValue") String typeValue);

    /**
     * 查询所有未删除的裂变活动
     *
     * @return
     */
    @Select("select t.id,t.name from t_image_activity t where t.is_delete = 0 order by t.start_time desc")
    List<ImageActivity> findEffectiveImageActivity();

    List<ImageActivityVO> findByPage(@Param("codeMap") Map<Integer, String> result,
                                     @Param("imageActivityId") Integer imageActivityId,
                                     @Param("pageNo") Integer pageNo,
                                     @Param("pageSize") Integer pageSize);

    List<ImageActivity> findDataByCondition(@Param("list") List<ImageActivity> list);

    List<ImageActivityVO> findByCreateMallCode(@Param("mallCode") String ourMallCode,
                                               @Param("imageActivityId") Integer imageActivityId,
                                               @Param("pageNo") Integer pageNo,
                                               @Param("pageSize") Integer pageSize);

    List<ImageActivity> findAllByCondition(@Param("codeMap") Map<Integer, String> param,
                                           @Param("imageActivity") ImageActivity imageActivity);

    List<ImageActivity> findImageActivityByCondition(@Param("list") List<ImageActivity> list);
}
